package com.woniuxy.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {
	
	//由字符串获取到入住日期与离店日期
	public ArrayList<java.sql.Date> getCheckTimes(String s) throws ParseException{
//		if(s==null||s.equals("")){
//			return null;
//		}
		ArrayList<java.sql.Date> dates = new ArrayList<>();
		String start = s.substring(0,10);
		String end = s.substring(13,23);
		SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd");
		Date start1 = sdf.parse(start);
		Date end1 = sdf.parse(end);
		Calendar ca = Calendar.getInstance();
		ca.setTime(end1);
		ca.add(Calendar.DATE, -1);
		end1 = ca.getTime();
		dates.add(new java.sql.Date(start1.getTime()));
		dates.add(new java.sql.Date(end1.getTime()));
		return dates;
	}
	
	public Date getRealCheckOutDate(Date end){
		Calendar ca = Calendar.getInstance();
		ca.setTime(end);
		ca.add(Calendar.DATE, 1);
		end = ca.getTime();
		return end;
	}
}
